package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.actity.domain.ActivityManager;
import com.ruoyi.actity.service.IActivityManagerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/frist/actity")
public class ActivityManagerController extends BaseController
{
    @Autowired
    private IActivityManagerService activityManagerService;

    /**
     * 查询活动管理列表
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityManager activityManager)
    {
        startPage();
        List<ActivityManager> list = activityManagerService.selectList(activityManager);
        return getDataTable(list);
    }

    /**
     * 导出活动管理列表
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:export')")
    @Log(title = "活动管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityManager activityManager)
    {
        List<ActivityManager> list = activityManagerService.selectList(activityManager);
        ExcelUtil<ActivityManager> util = new ExcelUtil<ActivityManager>(ActivityManager.class);
        util.exportExcel(response, list, "活动管理数据");
    }

    /**
     * 获取活动管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(activityManagerService.selectById(id));
    }

    /**
     * 新增活动管理
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:add')")
    @Log(title = "活动管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityManager activityManager)
    {
        return toAjax(activityManagerService.insert(activityManager));
    }

    /**
     * 修改活动管理
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:edit')")
    @Log(title = "活动管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityManager activityManager)
    {
        return toAjax(activityManagerService.update(activityManager));
    }

    /**
     * 删除活动管理
     */
    @PreAuthorize("@ss.hasPermi('frist:actity:remove')")
    @Log(title = "活动管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(activityManagerService.deleteByIds(ids));
    }
}
